#define _CRT_SECURE_NO_WARNINGS 1
//D
#include <iostream>
#include <string>
#include <map>
using namespace std;
string s[100010];
int main()
{
	int t = 0;
	cin >> t;
	while (t--)
	{
		int n = 0;
		cin >> n;
		map<string, int> a;
		for (int  i = 0; i < n; i++)
		{
			cin >> s[i];
			a[s[i]] = 1;
		}
		for (int i = 0; i < n; i++)
		{
			int ans = 0;
			for (int j = 0; j < s[i].size(); j++)
			{
				if (a[s[i].substr(0, j)] && a[s[i].substr(j, s[i].size() - j)])
				{
					ans = 1;
					break;
				}
			}
			cout << ans;
		}
		cout << endl;
	}
	return 0;
}
